#include "Blackboard.h"
#include <BWAPI\UnitType.h>

Blackboard::Blackboard(void)
{
	this->GameOver = false;
	this->file = fopen("Log.txt", "w");
	this->construtores;
	this->qntProbes = 0;
	this->qntPylons = 0;
	this->qntZealots = 0;
	this->qntZealotsEmAndamento = 0;
	this->qntNexus = 0;
	this->qntGateways = 0;
	this->qntGatewaysEmAndamento = 0;
	this->commandResources = HOLD;
	this->commandWar = CREATE_ARMY;
}



Blackboard::~Blackboard(void)
{
}

void Blackboard::updateUnitsCount(BWAPI::UnitType type, bool increment)
{
	int tmp = 1;
	if(!increment) tmp = -1;
	
	if(type == BWAPI::UnitTypes::Protoss_Pylon) {
		this->qntPylons += tmp;
		fprintf(this->file,"Quantidade de Pylons: %d diminuiu? %d\n",this->qntPylons, increment);
	} else if(type == BWAPI::UnitTypes::Protoss_Probe) {
		this->qntProbes += tmp;
		//fprintf(this->file,"Quantidade de Probes: %d  diminuiu? %d\n",this->qntProbes, increment);
	} else if(type == BWAPI::UnitTypes::Protoss_Nexus) {
		this->qntNexus += tmp;
		//fprintf(this->file,"Quantidade de Nexus: %d  diminuiu? %d\n",this->qntNexus, increment);
	} else if(type == BWAPI::UnitTypes::Protoss_Zealot) {
		this->qntZealots += tmp;
		//fprintf(this->file,"Quantidade de Zealots: %d diminuiu? %d\n",this->qntZealots, increment);
	} else if(type == BWAPI::UnitTypes::Protoss_Gateway) {
		this->qntGateways += tmp;
		fprintf(this->file,"Quantidade de Gateways: %d diminuiu? %d\n",this->qntGateways, increment);
	}
}

void Blackboard::writeLog(char* log) {
	fprintf(this->file,log);
}